/*******************************************************************************
 * Copyright (c) 2005, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 
 *******************************************************************************/

package net.brucey.dltk.blitzmax.debugger.preferences;

import net.brucey.dltk.blitzmax.core.BlitzMaxNature;
import net.brucey.dltk.blitzmax.debugger.BlitzMaxDebuggerConstants;
import net.brucey.dltk.blitzmax.debugger.BlitzMaxDebuggerPlugin;

import org.eclipse.core.resources.IProject;
import org.eclipse.dltk.debug.ui.preferences.ExternalDebuggingEngineOptionsBlock;
import org.eclipse.dltk.ui.preferences.AbstractConfigurationBlockPropertyAndPreferencePage;
import org.eclipse.dltk.ui.preferences.AbstractOptionsBlock;
import org.eclipse.dltk.ui.preferences.PreferenceKey;
import org.eclipse.dltk.ui.util.IStatusChangeListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;

public class BlitzMaxDebuggerPreferencePage extends
    AbstractConfigurationBlockPropertyAndPreferencePage {

  static PreferenceKey ENGINE_PATH = new PreferenceKey(
      BlitzMaxDebuggerPlugin.PLUGIN_ID,
      BlitzMaxDebuggerConstants.DEBUGGING_ENGINE_PATH_KEY);

  static PreferenceKey ENABLE_LOGGING = new PreferenceKey(
      BlitzMaxDebuggerPlugin.PLUGIN_ID,
      BlitzMaxDebuggerConstants.ENABLE_LOGGING);

  static PreferenceKey LOG_FILE_PATH = new PreferenceKey(
      BlitzMaxDebuggerPlugin.PLUGIN_ID, BlitzMaxDebuggerConstants.LOG_FILE_PATH);

  static PreferenceKey LOG_FILE_NAME = new PreferenceKey(
      BlitzMaxDebuggerPlugin.PLUGIN_ID, BlitzMaxDebuggerConstants.LOG_FILE_NAME);

  private static final String PREFERENCE_PAGE_ID = "net.brucey.dltk.blitzmax.preferences.debug.engines.debugger"; //$NON-NLS-1$
  private static final String PROPERTY_PAGE_ID = "net.brucey.dltk.blitzmax.propertyPage.debug.engines.debugger"; //$NON-NLS-1$

  /*
   * @see org.eclipse.dltk.ui.preferences.
   * AbstractConfigurationBlockPropertyAndPreferencePage
   * #createOptionsBlock(org.eclipse.dltk.ui.util.IStatusChangeListener,
   * org.eclipse.core.resources.IProject,
   * org.eclipse.ui.preferences.IWorkbenchPreferenceContainer)
   */
  @Override
  protected AbstractOptionsBlock createOptionsBlock(
      IStatusChangeListener newStatusChangedListener, IProject project,
      IWorkbenchPreferenceContainer container) {

    return new ExternalDebuggingEngineOptionsBlock(newStatusChangedListener,
        project, new PreferenceKey[] { ENGINE_PATH, ENABLE_LOGGING,
            LOG_FILE_PATH, LOG_FILE_NAME }, container) {

      @Override
      protected void createLoggingBlock(Composite composite) {
        /*
         * remove once the python active state debug runner supports setting up
         * the log file
         */
      }

      @Override
      protected PreferenceKey getDebuggingEnginePathKey() {
        return ENGINE_PATH;
      }

      @Override
      protected PreferenceKey getEnableLoggingPreferenceKey() {
        return ENABLE_LOGGING;
      }

      @Override
      protected PreferenceKey getLogFileNamePreferenceKey() {
        return LOG_FILE_NAME;
      }

      @Override
      protected PreferenceKey getLogFilePathPreferenceKey() {
        return LOG_FILE_PATH;
      }
    };
  }

  /*
   * @see org.eclipse.dltk.ui.preferences.
   * AbstractConfigurationBlockPropertyAndPreferencePage#getHelpId()
   */
  @Override
  protected String getHelpId() {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  protected String getNatureId() {
    return BlitzMaxNature.BLITZMAX_NATURE;
  }

  /*
   * @see org.eclipse.dltk.ui.preferences.
   * AbstractConfigurationBlockPropertyAndPreferencePage#getProjectHelpId()
   */
  @Override
  protected String getProjectHelpId() {
    // TODO Auto-generated method stub
    return null;
  }

  /*
   * @see org.eclipse.dltk.ui.preferences.
   * AbstractConfigurationBlockPropertyAndPreferencePage#setDescription()
   */
  @Override
  protected void setDescription() {
    setDescription(PreferenceMessages.PreferencesDescription);
  }

  /*
   * @see org.eclipse.dltk.ui.preferences.
   * AbstractConfigurationBlockPropertyAndPreferencePage#setPreferenceStore()
   */
  @Override
  protected void setPreferenceStore() {
    setPreferenceStore(BlitzMaxDebuggerPlugin.getDefault().getPreferenceStore());
  }

  /*
   * @see org.eclipse.dltk.internal.ui.preferences.PropertyAndPreferencePage#
   * getPreferencePageId()
   */
  @Override
  protected String getPreferencePageId() {
    return PREFERENCE_PAGE_ID;
  }

  /*
   * @see org.eclipse.dltk.internal.ui.preferences.PropertyAndPreferencePage#
   * getPropertyPageId()
   */
  @Override
  protected String getPropertyPageId() {
    return PROPERTY_PAGE_ID;
  }
}
